package cn.knightzz.service.impl;

import cn.knightzz.entity.SysUserEvent;
import cn.knightzz.mapper.SysUserEventMapper;
import cn.knightzz.service.SysUserEventService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author knightzz
 * @since 2021-05-19
 */
@Service
public class SysUserEventServiceImpl extends ServiceImpl<SysUserEventMapper, SysUserEvent> implements SysUserEventService {

    @Resource
    SysUserEventMapper userEventMapper;

    @Override
    public void addUserEvent(SysUserEvent userEvent) {
        try {
            userEventMapper.insert(userEvent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void updateUserEvent(SysUserEvent userEvent) {

        QueryWrapper<SysUserEvent> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("event_id" , userEvent.getEventId());
        try {
            userEventMapper.update(userEvent , queryWrapper);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void deleteUserEvent(Long id) {
        try {
            userEventMapper.deleteById(id);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
